package com.itheima.stringdemo;

public class StringDemo11 {
    public static void main(String[] args) {
        //1.定义一个字符串记录身份证号码
        String id = "321281202001011234";

        //2.获取身份证对应的年月日
        String year = id.substring(6, 10);
        String month = id.substring(10, 12);
        String day = id.substring(12, 14);

        //3.获取性别
        char gender = id.charAt(16);//'3' --> 3
        //利用ASCII码表进行转换
        //'0' --> 48
        //'1' --> 49
        //'2' --> 50
        //'3' --> 51
        //'4' --> 52
        //'5' --> 53
        //'6' --> 54
        //'7' --> 55
        //'8' --> 56
        //'9' --> 57
        int num = gender - 48;

        //4.输入年月日
        System.out.println("出生年月日：" + year + "年" + month + "月" + day + "日");

        //5.对num进行判断
        if(num%2==1){
            System.out.println("性别为：男");
        }else {
            System.out.println("性别为：女");
        }
    }
}
